<template>
  <el-select clearable  placeholder="请选择频道" :value="value" @change="onChange">
    <el-option
      v-for="item in channels"
      :key="item.id"
      :label="item.name"
      :value="item.id"
    ></el-option>
  </el-select>
</template>

<script>
import { reqChannels } from '@/api/article'
export default {
  // 发送请求，获取频道数据
  props: ['value'],
  data () {
    return {
      channels: []
    }
  },
  created () {
    this.getChannels()
  },
  methods: {
    async getChannels () {
      const res = await reqChannels()
      this.channels = res.data.data.channels
    },
    onChange (value) {
      this.$emit('input', value)
    }
  }
}
</script>

<style>

</style>
